﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Delegate.aspx.cs" Inherits="EDMS.Delegate" %>

<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxDataView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.2.Linq, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Data.Linq" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../Scripts/artDialog.js" type="text/javascript"></script>
    <script src="../Scripts/scrollable.js" type="text/javascript"></script>
    <script src="../plugins/iframeTools.js" type="text/javascript"></script>
    <link href="../Css/css.css" rel="stylesheet" type="text/css" />
    <link href="../Css/default.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/SearchJs.js" type="text/javascript"></script>
    <title></title>
    <script language="javascript" type="text/javascript">
        $(function () {
            $("#wizard").scrollable({
                onSeek: function (event, i) {
                    $("#status li").removeClass("active").eq(i).addClass("active");   //eq(i)获取匹配的元素
                },
                onBeforeSeek: function (event, i) {
                    if (i == 1) {
                        var community = txtSelectC.GetText();
                        if (community == "XXXX" || community == "") {
                            art.dialog.alert("请选择要参加选举！");
                            return false;
                        }
                    }
                    if (i == 3) {
                        var name = $("#Name").val();
                        var mobile = $("#WTMobile").val();
                        if (name == "") {
                            art.dialog.alert("请输入您的姓名！");
                            $("#Name").focus();
                            return false;
                        }
                        if (mobile == "") {
                            art.dialog.alert("请输入您的联系方式！");
                            $("#WTMobile").focus();
                            return false;
                        }
                    }
                    if (i == 4) {
                        var name = username.GetText();
                        var card = idcard.GetText();
                        if (name == "" && card == "") {
                            art.dialog.alert("请输入被委托人情况,并进行选择！");
                            return false;
                        }
                    }
                }
            });
        });


        // <![CDATA[


        function getAjax() {
            var wtrxm = $("#Name").val();       //委托人姓名
            var wtrcard = $("#IDCard").val();   //委托人身份证号码
            var wtrmobile = $("#WTMobile").val(); //委托人联系方式
            var bwtrxm = username.GetValue();    //被委托人姓名
            var bwtrcard = idcard.GetValue();  //被委托人身份证号码
            var xjbh = xjbhc.GetText();        //选举编号
            var xjlxfs = xjphone.GetText();  //选举社区的联系方式
            $.ajax({
                type: "POST",
                url: "IsDelegate.ashx",
                data: { bwtrxm: bwtrxm, bwtrcard: bwtrcard, wtrxm: wtrxm, wtrcard: wtrcard, wtmobile: wtrmobile, xjbho: xjbh },
                success: function (msg) {
                    if (msg == "sorry") {
                        art.dialog.alert("对不起，此人的委托次数不能超过三次，请重新选择被委托人！");
                    }
                    else if (msg == "none") {
                        art.dialog.alert("对不起，此选民不存在不能进行委托！");
                    }
                    else if (msg == "success") {
                        document.location.href("success.aspx?wtrname=" + wtrxm + "&bwtrname=" + bwtrxm + "&xjphones=" + xjlxfs);
                    }
                }
            });
        }
        function getMobile() {
            var xjbh = xjbhc.GetText();        //选举编号
            $.ajax({
                type: "POST",
                //dataType: "JSON",
                url: "Community.ashx",
                data: { xjbho: xjbh },
                success: function (data) {
                    if (data != "") {
                        xjphone.SetText(data.jsondata[0].xjphone);
                        gg.SetText(data.jsondata[0].nr);
                    }

                }
            });
        }
        function getCommunity() {
            var names = $("#newTag").val();
            if (names != "") {
                $.ajax({
                    type: "POST",
                    url: "Community.ashx",
                    data: { name: names },
                    success: function (data) {
                        $("#lblxjContent").val(data[0]);
                    }
                });
            }

        }

        //单选
        function grid_SelectionChanged(s, e) {
            s.GetSelectedFieldValues("xjmc;xjbh", GetSelectedFieldValuesCallback);
        }
        function GetSelectedFieldValuesCallback(values) {
            if (values != "") {
                txtSelectC.SetText(values[0][0]);
                xjbhc.SetText(values[0][1]);
            }

        }
        function grids_SelectionChanged(s, e) {
            s.GetSelectedFieldValues("xmxm;sfzh", GetSelectedFieldValuesCallbacks);
        }
        function GetSelectedFieldValuesCallbacks(values) {
            if (values != "") {
                username.SetText(values[0][0]);
                idcard.SetText(values[0][1]);
            }

        }
        function OnGridFocusedRowChanged() {
            gvQuery.GetRowValues(gvQuery.GetFocusedRowIndex(), 'xmxm;sfzh', OnGetRowValues);
        }

        function OnGetRowValues(values) {
            username.SetText(values[0]);
            idcard.SetText(values[1])
        }

        // ]]>
    </script>
</head>
<body>
    <form id="Form2" runat="server">
    <div id="main">
        <div id="wizard">
            <ul id="status">
                <li class="active"><strong>1.</strong>查询社区选举</li>
                <li><strong>2.</strong>阅读投票通知</li>
                <li><strong>3.</strong>填写个人信息</li>
                <li><strong>4.</strong>选择被委托人</li>
                <li><strong>5.</strong>完成</li>
            </ul>
            <div class="items">
                <div class="page">
                    <h3>
                        查询选举社区</h3>
                    <div id="tagDiv" style="width: 100%">
                        <p style="text-align: center;">
                            <table width="100%">
                                <tr>
                                    <td style="width: 20%; text-align: right;">
                                        选择社区：
                                    </td>
                                    <td style="width: 10%">
                                        <%--<input type="text" class="input" id="newTag" autocomplete="off" value="请输入社区名称" /></div>--%>
                                        <dx:ASPxTextBox ID="newTag" runat="server" Width="200px" NullText="请输入社区名称">
                                        </dx:ASPxTextBox>
                                    </td>
                                    <td style="width: 20%">
                                        <dx:ASPxButton ID="btnSearchCm" Width="80px" runat="server" Text="查询" AutoPostBack="False"
                                            ClientInstanceName="searchCm" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css"
                                            CssPostfix="Office2010Blue" SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css">
                                            <ClientSideEvents Click="function(s,e){ gvQueryC.PerformCallback(); }" />
                                        </dx:ASPxButton>
                                    </td>
                                </tr>
                            </table>
                            <table>
                                <tr>
                                    <td style="text-align: right;">
                                        您所选社区名称为：
                                    </td>
                                    <td colspan="2" style="text-align: left;">
                                        <dx:ASPxTextBox ID="txtSelectC" runat="server" Width="200px" Text="XXXX" ForeColor="Red"
                                            ReadOnly="True">
                                            <Border BorderStyle="None" />
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                            </table>
                            <table>
                                <tr>
                                    <td>
                                        (注意:请在下方查询选举社区如确认此选举社区请点击下一步完成选举！)
                                    </td>
                                </tr>
                            </table>
                        </p>
                    </div>
                    <div style="width: 100%; float: left;">
                        <dx:ASPxCallbackPanel ID="ASPxCallbackPanel1" ClientInstanceName="pp" runat="server"
                            Width="100%">
                            <PanelCollection>
                                <dx:PanelContent runat="server" SupportsDisabledAttribute="True">
                                    <dx:ASPxGridView ID="gvCommunitys" runat="server" ClientInstanceName="gvQueryC" AutoGenerateColumns="False"
                                        KeyFieldName="xjbh" Width="100%" OnCustomCallback="gvCommunitys_CustomCallback"
                                        CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" CssPostfix="Office2010Blue"
                                        OnSelectionChanged="gvCommunitys_SelectionChanged">
                                        <Columns>
                                            <dx:GridViewCommandColumn ShowInCustomizationForm="True" ShowSelectCheckbox="True"
                                                VisibleIndex="0" Width="10px">
                                                <ClearFilterButton Visible="True">
                                                </ClearFilterButton>
                                            </dx:GridViewCommandColumn>
                                            <dx:GridViewDataTextColumn FieldName="xjmc" ShowInCustomizationForm="True" VisibleIndex="1"
                                                Caption="选举名称">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Caption="选举编号" FieldName="xjbh" ShowInCustomizationForm="True"
                                                Visible="False" VisibleIndex="2">
                                            </dx:GridViewDataTextColumn>
                                        </Columns>
                                        <ClientSideEvents SelectionChanged="grid_SelectionChanged" />
                                        <SettingsBehavior AllowSelectSingleRowOnly="True" AllowGroup="False" AllowSort="False"
                                            AllowDragDrop="False" />
                                        <SettingsPager PageSize="5" SEOFriendly="Enabled">
                                        </SettingsPager>
                                        <SettingsText EmptyDataRow="没有记录" />
                                        <Images SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css">
                                            <LoadingPanelOnStatusBar Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                                            </LoadingPanelOnStatusBar>
                                            <LoadingPanel Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                                            </LoadingPanel>
                                        </Images>
                                        <ImagesFilterControl>
                                            <LoadingPanel Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                                            </LoadingPanel>
                                        </ImagesFilterControl>
                                        <Styles CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" CssPostfix="Office2010Blue">
                                            <Header ImageSpacing="5px" SortingImageSpacing="5px">
                                            </Header>
                                            <LoadingPanel ImageSpacing="5px">
                                            </LoadingPanel>
                                        </Styles>
                                        <StylesPager>
                                            <PageNumber ForeColor="#3E4846">
                                            </PageNumber>
                                            <Summary ForeColor="#1E395B">
                                            </Summary>
                                        </StylesPager>
                                        <StylesEditors ButtonEditCellSpacing="0">
                                            <ProgressBar Height="21px">
                                            </ProgressBar>
                                        </StylesEditors>
                                    </dx:ASPxGridView>
                                </dx:PanelContent>
                            </PanelCollection>
                        </dx:ASPxCallbackPanel>
                        <dx:LinqServerModeDataSource ID="LinqServerModeDataSource2" runat="server" ContextTypeName="DAL.DataClassesDataContext"
                            TableName="Xjdj" />
                    </div>
                    <div class="btn_nav">
                        <input type="button" class="next right" value="下一步&raquo;" onclick="getMobile()" />
                    </div>
                </div>
                <div class="page">
                    <h3>
                        选民投票选举通知</h3>
                    <p style="text-indent: 2em;">
                        <dx:ASPxLabel ID="lblgg" runat="server" Text="" ClientInstanceName="gg">
                        </dx:ASPxLabel>
                    </p>
                    <div class="btn_nav">
                        <input type="button" class="prev" style="float: left" value="&laquo;上一步" />
                        <input type="button" class="next right" value="下一步&raquo;" />
                    </div>
                </div>
                <div class="page">
                    <h3>
                        填写个人信息提问问题</h3>
                    <div class="question">
                        <label>
                            姓 名：</label><br />
                        <input type="text" class="input" id="Name" />
                        <label>
                            <font color="red">&nbsp;&nbsp;☀</font></label>
                    </div>
                    <div class="question">
                        <label>
                            身份证号码：</label><br />
                        <input type="text" class="input" id="IDCard" name="card" /></div>
                    <div class="question">
                        <label>
                            联系方式：</label><br />
                        <input type="text" class="input" id="WTMobile" name="mobile" />
                        <label>
                            <font color="red">&nbsp;&nbsp;☀</font></label></div>
                    <div class="question">
                        <label>
                            <font color="red">(注意：带☀号的为必填项)</font>
                        </label>
                    </div>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <div class="btn_nav">
                        <input type="button" class="prev" style="float: left" value="&laquo;上一步" />
                        <input type="button" class="next right" value="下一步&raquo;" />
                    </div>
                    <div style="width: 98%; float: left; font-size: medium; line-height: 30px; text-align: center;">
                        <font color="red">选民可通过电话的方式完成委托选举,如您没有联系方式请选择电话委托完成委托 </font>
                    </div>
                    <div style="width: 98%; float: left; font-size: medium; text-align: left; padding-left: 50px;">
                        <font color="red">委托电话：
                            <dx:ASPxLabel ID="lblxjmobile" runat="server" ClientInstanceName="xjphone" Text="ASPxLabel">
                            </dx:ASPxLabel>
                        </font>
                    </div>
                </div>
                <div class="page">
                    <h3>
                        选择被委托人</h3>
                    <p>
                        请点击“确定”按钮完成委托计划。</p>
                    <div style="width: 98%; float: left;">
                        <div style="width: 15%; float: left;">
                            <label>
                                被委托人姓名：</label></div>
                        <div style="width: 20%; float: left;">
                            <dx:ASPxTextBox ID="wtName" NullText="请输入委托人姓名" runat="server" ClientInstanceName="username"
                                Style="width: 100%">
                            </dx:ASPxTextBox>
                        </div>
                        <div style="width: 25%; float: left;">
                            <label>
                                &nbsp;&nbsp;&nbsp;&nbsp;被委托人身份证号码：</label></div>
                        <div style="width: 23%; float: left;">
                            <dx:ASPxTextBox ID="wtIDcard" NullText="请输入被委托人身份证号码" runat="server" ClientInstanceName="idcard"
                                Style="width: 100%">
                            </dx:ASPxTextBox>
                        </div>
                        <div style="width: 15%; float: right;">
                            <dx:ASPxButton ID="btn" runat="server" Text="查询" ClientInstanceName="search_name"
                                AutoPostBack="false">
                                <ClientSideEvents Click="function(s,e){ var str1 =username.GetValue(); 
                            var str2 = idcard.GetValue();
                            var str3 = '&';
                            var str;
                            str = str1 + str3 + str2;
                            gvQuery.PerformCallback(str); }" />
                            </dx:ASPxButton>
                        </div>
                    </div>
                    <dx:ASPxCallbackPanel ID="QueryPanel" runat="server" ClientInstanceName="Query" Width="98%">
                        <PanelCollection>
                            <dx:PanelContent>
                                <dx:ASPxGridView ID="gvShow" runat="server" KeyFieldName="sfzh" AutoGenerateColumns="False"
                                    ClientInstanceName="gvQuery" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css"
                                    CssPostfix="Office2010Blue" OnCustomCallback="gvShow_CustomCallback" Width="98%">
                                    <Columns>
                                        <dx:GridViewCommandColumn ShowInCustomizationForm="True" ShowSelectCheckbox="True"
                                            VisibleIndex="0" Width="10px">
                                            <ClearFilterButton Visible="True">
                                            </ClearFilterButton>
                                        </dx:GridViewCommandColumn>
                                        <dx:GridViewDataTextColumn Caption="姓名" FieldName="xmxm" ShowInCustomizationForm="True"
                                            VisibleIndex="1">
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataComboBoxColumn Caption="性别" FieldName="xb" ShowInCustomizationForm="True"
                                            VisibleIndex="2">
                                            <PropertiesComboBox Spacing="0" ValueType="System.String">
                                                <Items>
                                                    <dx:ListEditItem Text="男" Value="M" />
                                                    <dx:ListEditItem Text="女" Value="F" />
                                                </Items>
                                            </PropertiesComboBox>
                                        </dx:GridViewDataComboBoxColumn>
                                        <dx:GridViewDataTextColumn Caption="生日" FieldName="sr" ShowInCustomizationForm="True"
                                            VisibleIndex="3">
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn Caption="身份证号" FieldName="sfzh" ShowInCustomizationForm="True"
                                            VisibleIndex="4">
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn Caption="手机号码" FieldName="sjhm" ShowInCustomizationForm="True"
                                            VisibleIndex="5">
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataComboBoxColumn Caption="是否被委托" FieldName="flag" ShowInCustomizationForm="True"
                                            VisibleIndex="6" Width="87px">
                                            <PropertiesComboBox Spacing="0" ValueType="System.String">
                                                <Items>
                                                    <dx:ListEditItem Text="是" Value="Y" />
                                                    <dx:ListEditItem Text="否" Value="N" />
                                                </Items>
                                            </PropertiesComboBox>
                                            <HeaderStyle HorizontalAlign="Center" />
                                        </dx:GridViewDataComboBoxColumn>
                                        <dx:GridViewDataTextColumn Caption="剩余被委托次数" FieldName="sybwtcs" ShowInCustomizationForm="True"
                                            VisibleIndex="7">
                                        </dx:GridViewDataTextColumn>
                                    </Columns>
                                    <SettingsBehavior AllowSelectSingleRowOnly="True" AllowDragDrop="False" AllowGroup="False"
                                        AllowSort="False" />
                                    <ClientSideEvents SelectionChanged="grids_SelectionChanged" />
                                    <SettingsText EmptyDataRow="没有记录" />
                                    <Images SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css">
                                        <LoadingPanelOnStatusBar Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                                        </LoadingPanelOnStatusBar>
                                        <LoadingPanel Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                                        </LoadingPanel>
                                    </Images>
                                    <ImagesFilterControl>
                                        <LoadingPanel Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                                        </LoadingPanel>
                                    </ImagesFilterControl>
                                    <Styles CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" CssPostfix="Office2010Blue">
                                        <Header ImageSpacing="5px" SortingImageSpacing="5px">
                                        </Header>
                                        <LoadingPanel ImageSpacing="5px">
                                        </LoadingPanel>
                                    </Styles>
                                    <StylesPager>
                                        <PageNumber ForeColor="#3E4846">
                                        </PageNumber>
                                        <Summary ForeColor="#1E395B">
                                        </Summary>
                                    </StylesPager>
                                    <StylesEditors ButtonEditCellSpacing="0">
                                        <ProgressBar Height="21px">
                                        </ProgressBar>
                                    </StylesEditors>
                                </dx:ASPxGridView>
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxCallbackPanel>
                    <br />
                    <br />
                    <br />
                    <div class="btn_nav">
                        <input type="button" class="prev" style="float: left" value="&laquo;上一步" />
                        <input type="button" class="next right" id="btnDelegate" onclick="getAjax();" value="确认委托" />
                    </div>
                </div>
            </div>
        </div>
        <div style="display: none">
            <dx:ASPxTextBox ID="txtxjbhc" ClientInstanceName="xjbhc" runat="server" Width="170px">
            </dx:ASPxTextBox>
        </div>
    </div>
    </form>
    <br />
    <br />
    <br />
    </div>
    <br />
    <br />
    <br />
    <script language="javascript" type="text/javascript">
        //        $("#newTag").click(function () {
        //            if ($("#newTag").val() == "请输入社区名称") {
        //                $("#newTag").val("");
        //                $("#newTag").focus();
        //            }
        //        })
        //        $("#newTag").blur(function () {
        //            if ($("#newTag").val() == "") {
        //                $("#newTag").val("请输入社区名称");
        //                $("#newTag").focus();
        //            }
        //        })
        //        $("#newTag").keyup(function (e) {
        //            if (e.keyCode != 40 && e.keyCode != 38) {  //上 下
        //                currentTxt = $("#newTag").val();
        //                pinyinOption();
        //            }
        //        }).focus(function () {
        //            this.select();
        //        });
    </script>
    <dx:LinqServerModeDataSource ID="LinqServerModeDataSource1" runat="server" ContextTypeName="DAL.DataClassesDataContext"
        TableName="Tb_Elector" />
</body>
</html>
